﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using SzCourt.Logic.BLL;
using SzCourt.Logic.NBL.DBEntities;

namespace SzCourt.WebSite.manager
{
    public partial class anyouEdit : System.Web.UI.Page
    {
        public string _FirstList = string.Empty;
        public string _SecondList = string.Empty;
        public string _ThirdList = string.Empty;
        public string _FourthList = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!AdminSession.SessionBox.CheckUserSession())
            {
                Response.Redirect("/manager/login.aspx");
            }
            GetCauseOfActionList();
        }

        //获取案由类别
        private void GetCauseOfActionList()
        {
            PreCase bll = new PreCase();
            CauseOfActionList result = (CauseOfActionList)bll.GetCauseOfActionList();

            if (result != null)
            {
                this.sltFirstList.DataSource = result.FirstList;
                this.sltFirstList.DataTextField = "CauseOfAction";
                this.sltFirstList.DataValueField = "CauseOfActionID";
                this.sltFirstList.DataBind();

                _FirstList = JavaScriptConvert.SerializeObject(result.FirstList);
                _SecondList = JavaScriptConvert.SerializeObject(result.SecondList);
                _ThirdList = JavaScriptConvert.SerializeObject(result.ThirdList);
                _FourthList = JavaScriptConvert.SerializeObject(result.FourthList);
            }
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            pCauseOfAction param = new pCauseOfAction();
            param.CauseOfAction = this.txtCauseOfAction.Value;
            param.CauseOfActionID = int.Parse(this.hdnID.Value);
            PreCase bll = new PreCase();
            bool result = (bool)bll.EditCauseOfAction(param);

            if (result)
            {
                this.divMessage.InnerHtml = "修改案由成功!";
                Response.Redirect("/manager/anyouEdit.aspx");
            }
            else
            {
                this.divMessage.InnerHtml = "修改案由成功!";
            }
        }
    }
}